home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 December / PCWorld_2007-12_cd.bin / domacnost a kancelar / autoit / autoit-v3-setup.exe / Examples / Helpfile / _IEFormElementSetValue.au3 < prev    next >
Text File  |  2007-09-08  |  3KB  |  83 lines

  1. ; *******************************************************
  2. ; Example 1 - Open a browser with the form example, set the value of a text form element
  3. ; *******************************************************
  4. ;
  5. #include <IE.au3>
  6. $oIE = _IE_Example ("form")
  7. $oForm = _IEFormGetObjByName ($oIE, "ExampleForm")
  8. $oText = _IEFormElementGetObjByName ($oForm, "textExample")
  9. _IEFormElementSetValue ($oText, "Hey! This works!")
  10.  
  11. ; *******************************************************
  12. ; Example 2 - Get a reference to a specific form element and set its value.
  13. ;                In this case, submit a query to the Google search engine
  14. ; *******************************************************
  15. ;
  16. #include <IE.au3>
  17. $oIE = _IECreate ("http://www.google.com")
  18. $oForm = _IEFormGetObjByName ($oIE, "f")
  19. $oQuery = _IEFormElementGetObjByName ($oForm, "q")
  20. _IEFormElementSetValue ($oQuery, "AutoIt IE.au3")
  21. _IEFormSubmit ($oForm)
  22.  
  23. ; *******************************************************
  24. ; Example 3 - Login to Hotmail
  25. ; *******************************************************
  26. ;
  27. #include <IE.au3>
  28. ; Create a browser window and navigate to hotmail
  29. $oIE = _IECreate ("http://www.hotmail.com")
  30.  
  31. ; get pointers to the login form and username, password and signin fields
  32. $o_form = _IEFormGetObjByName ($oIE, "f1")
  33. $o_login = _IEFormElementGetObjByName ($o_form, "login")
  34. $o_password = _IEFormElementGetObjByName ($o_form, "passwd")
  35. $o_signin = _IEFormElementGetObjByName ($o_form, "SI")
  36.  
  37. $username = "your username here"
  38. $password = "your password here"
  39.  
  40. ; Set field values and submit the form
  41. _IEFormElementSetValue ($o_login, $username)
  42. _IEFormElementSetValue ($o_password, $password)
  43. _IEAction ($o_signin, "click")
  44.  
  45. ; *******************************************************
  46. ; Example 4 - Set the value of an INPUT TYPE=FILE element
  47. ;                (security restrictions prevent using _IEFormElementSetValue)
  48. ; *******************************************************
  49. ;
  50. #include <IE.au3>
  51.  
  52. $oIE = _IE_Example("form")
  53. $oForm = _IEFormGetObjByName($oIE, "ExampleForm")
  54. $oInputFile = _IEFormElementGetObjByName($oForm, "fileExample")
  55.  
  56. ; Assign input focus to the field and then send the text string
  57. _IEAction($oInputFile, "focus")
  58. Send("C:\myfile.txt")
  59.  
  60. ; *******************************************************
  61. ; Example 5 - Set the value of an INPUT TYPE=FILE element
  62. ;                Same as previous example, but with invisible window
  63. ;                (security restrictions prevent using _IEFormElementSetValue)
  64. ; *******************************************************
  65. ;
  66. #include <IE.au3>
  67.  
  68. $oIE = _IE_Example("form")
  69.  
  70. ; Hide the browser window to demonstrate sending text to invisible window
  71. _IEAction($oIE, "invisible")
  72.  
  73. $oForm = _IEFormGetObjByName($oIE, "ExampleForm")
  74. $oInputFile = _IEFormElementGetObjByName($oForm, "fileExample")
  75.  
  76. ; Assign input focus to the field and then send the text string
  77. _IEAction($oInputFile, "focus")
  78. $hIE = _IEPropertyGet($oIE, "hwnd")
  79. ControlSend($hIE, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "C:\myfile.txt")
  80.  
  81. MsgBox(0, "Success", "Value set to C:\myfile.txt")
  82. _IEAction($oIE, "visible")
  83.